all files / src/ interfaces.ts

100% Statements 0/0
100% Branches 0/0
100% Functions 0/0
100% Lines 0/0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                                                                                                                     
import {Stream, MemoryStream} from 'xstream';
import {Response as SuperagentResponse} from 'superagent';
 
export interface Attachment {
  name: string;
  path?: string;
  filename?: string;
}
 
export interface AgentOptions {
  key: string;
  cert: string;
}
 
export interface RequestOptions {
  url: string;
  method?: string;
  query?: Object;
  send?: Object | string;
  headers?: Object;
  accept?: string;
  type?: string;
  user?: string;
  password?: string;
  field?: Object;
  progress?: boolean;
  attach?: Array<Attachment>;
  agent?: AgentOptions;
  withCredentials?: boolean;
  redirects?: number;
  category?: string;
  lazy?: boolean;
  responseType?: string;
  ok?: ((res: SuperagentResponse) => boolean);
  _error?: any;
  _namespace?: Array<string>;
}
 
export type RequestInput = RequestOptions | string;
 
export interface ResponseStream {
  request: RequestOptions;
}
 
export interface Response extends SuperagentResponse {
  total?: number; // Not sure what is this. Stays here to avoid breaking change
  request: RequestOptions;
}
 
export interface HTTPSource {
  filter(
    predicate: (request: RequestOptions) => boolean,
    scope?: string
  ): HTTPSource;
  select(category?: string): Stream<MemoryStream<Response> & ResponseStream>;
  isolateSource(source: HTTPSource, scope: string): HTTPSource;
  isolateSink(sink: Stream<RequestInput>, scope: string): Stream<RequestInput>;
}